#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N=100003,PIN=1061109567,NIN=-1061109568;
struct List{
	int len_list=0,e[N*2],ne[N*2],h[N];
	void add_once(int a,int b){
		e[len_list]=b;
		ne[len_list]=h[a];
		h[a]=len_list++;
	}
	void add_twice(int a,int b){
		add_once(a,b);
		add_once(b,a);
	}
}gph,ext;
int n,root,A,B,dep[N],son[N],arr[N],dfn[N],ls[N],dis[N],g[N]; bool f[N];
void dfs1(int u,int fa,int depth,int& p){
	dep[u]=depth,ls[depth]=u,arr[++p]=u,dfn[u]=p,son[u]=0;
	if(depth>A) ext.add_once(ls[depth-A],u);
	for(int i=gph.h[u];i>=0;i=gph.ne[i]){
		if(gph.e[i]==fa) continue;
		dfs1(gph.e[i],u,depth+1,p);
		son[u]+=son[gph.e[i]]+1;
	}
}
void dfs2(int u,int fa,const int& p){
	int i; dis[u]=(u<=p)?0:PIN;
	for(i=gph.h[u];i>=0;i=gph.ne[i]){
		if(gph.e[i]==fa) continue;
		else dfs2(gph.e[i],u,p);
		dis[u]=min(dis[u],dis[gph.e[i]]+1);
	}
}
namespace SGT{
	struct Node{
		int l,r,chk;
	}node[N*3];
	void push_down(int u){
		node[u*2  ].chk=max(node[u*2  ].chk,node[u].chk);
		node[u*2+1].chk=max(node[u*2+1].chk,node[u].chk);
	}
	void build(int u,int l,int r){
		node[u]={l,r,NIN};
		if(l<r){
			int mid=(l+r)/2;
			build(u*2  ,l,mid  );
			build(u*2+1,mid+1,r);
		}
	}
	void modify(int u,int l,int r,int x){
		if(l>r) return ;
		if(node[u].l>=l&&node[u].r<=r)
			node[u].chk=max(node[u].chk,x);
		else{
			push_down(u);
			int mid=(node[u].l+node[u].r)/2;
			if(l<=mid) modify(u*2  ,l,r,x);
			if(r> mid) modify(u*2+1,l,r,x);
		}
	}
	int query(int u,int k){
		if(node[u].l==node[u].r) return node[u].chk;
		int mid=(node[u].l+node[u].r)/2; push_down(u);
		return query(u*2+(k>mid),k);
	}
}
void dfs3(int u,int fa){
	for(int i=gph.h[u];i>=0;i=gph.ne[i]){
		if(gph.e[i]==fa) continue;
		else dfs3(gph.e[i],u);
		g[u]=min(g[u],g[gph.e[i]]+1);
	}
	if(ext.h[u]==-1) f[u]=!(dis[u]<=B);
	else for(int i=ext.h[u];i>=0;i=ext.ne[i])
		if(dep[ext.e[i]]-SGT::query(1,dfn[ext.e[i]])>B){
			f[u]=1; break;
		}
	if(!f[u]) g[u]=0;
	SGT::modify(1,dfn[u],dfn[u]+son[u],dep[u]-g[u]);
}
bool check(int p){
	dfs2(root,0,p);
	for(int i=1;i<=n;i++) f[i]=0,g[i]=PIN;
	SGT::build(1,1,n),dfs3(root,0);
	return !f[root];
}
int binary(int l,int r){
	while(l<r){
		int mid=(l+r)/2;
		check(mid)?(r=mid):(l=mid+1);
	}
	return r;
}
int read(){
	char ch; int x=0;
	do ch=getchar();
	while(ch<'0'||ch>'9');
	while(ch>='0'&&ch<='9')
		x=x*10+(ch-'0'),ch=getchar();
	return x;
}
int main(){
	freopen("nim.in","r",stdin);
	freopen("nim.out","w",stdout);
	int i,x,y,s1;
	n=read(),root=read(),A=read(),B=read();
	if(A<=B){ putchar('1'); return 0; }
	memset(gph.h,-1,sizeof gph.h);
	memset(ext.h,-1,sizeof ext.h);
	for(i=1;i<n;i++){
		x=read(),y=read();
		gph.add_twice(x,y);
	}
	dfs1(root,0,1,s1=0);
	printf("%d\n",binary(1,n));
	fclose(stdin);
	fclose(stdout);
	return 0;
}
